package day14.atomdemo02;

/**
 * @author Xiao
 * @date 2021/8/7
 */
public class MyAtom01 implements Runnable{
    private volatile int count;
    private Object lock = new Object();
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            synchronized (lock) {
                count++;
                System.out.println("阿良送你" +
                        count + "个冰淇淋");
            }
        }
    }
}
